.EXPORT_ALL_VARIABLES:

.PHONY: clean all

COMMON_DIR = ../../Common

ROOTCFLAGS   := $(shell root-config --cflags)
ROOTLIBS     := $(shell root-config --libs)
ROOTGLIBS    := $(shell root-config --glibs)
ROOTINC      := -I$(shell root-config --incdir)

ALLIBS  = -lm $(ROOTLIBS) $(ROOTGLIBS) -L$(COMMON_DIR) 

CC		= gcc
CPP             = g++
CFLAGS		= -O2 -pipe -Wall -W -Woverloaded-virtual $(ROOTCFLAGS)

INCLUDES        =  -I./
LFLAGS		=  -O2 -g 
LIBS 		= $(ALLIBS) 
#SOFLAGS = -dynamiclib -single_module -undefined dynamic_lookup

O_FILES = \
	Peaks.o \
	Step.o \
	MacroDictionary.o

all: $(COMMON_DIR)/libMacro.a
	@echo Done

$(COMMON_DIR)/libMacro.a: $(O_FILES)
	$(AR) cru $@ $^

%.o: %.cc %.hh
	$(CPP) $(CFLAGS) $(INCLUDES) -c $< -o $@

#---- Root stuff

DEPENDENCIES = \
	Peaks.hh \
	Step.hh \
	RootLinkDef.h

MacroDictionary.o: MacroDictionary.cc MacroDictionary.h
	 $(CPP) -fPIC $(CFLAGS) $(INCLUDES) -c $<

MacroDictionary.cc: $(DEPENDENCIES)
	 rm -f MacroDictionary.cc MacroDictionary.h; rootcint -f $@ -c $(INCLUDES) $(DEPENDENCIES)

#--------------------------------------------------

tar:
	@echo "creating zipped tar-ball ... "
	@cd ..; tar -chvzf macros/macros.tar.gz macros/Makefile macros/*.hh macros/*.cc;

#--------------------------------------------------
clean:
	rm  -f *.o MacroDictionary.* $(COMMON_DIR)/libMacro.a
